<?php
/**
 * common model file Created by PhpStorm.
 * User: wumengmeng
 * Date: 2020/05/20
 * Time: 14:22
 */

namespace HiCommon\Model;

class AppDownload extends Base
{
    
    protected $table = 'app_download';
    
    protected $guarded = [];
    
    //public $timestamps = false;
    
    /**
     * 应该被调整为日期的属性
     *
     * @var array
     */
    protected $dates = [
    ];
    
        /**
         * 获取图片可用链接
         *
         * @return array
         * @author wumengmeng <wu_mengmeng@foxmail.com>
         */
        public function getImgUrlAttribute($value)
        {
            $arr_data = [
              'src'=>$value,
              'full_src'=>oss_full_url($value),
            ];
            return $arr_data;
        }
        
    /**
     * 扩展信息
     *
     * @return array
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function getExtendAttribute()
    {
        $s_created_at = $this->created_at;
        $arr_data               = $this->arr_state_display_name();
        $arr_data['created_at'] = ymd_friendly_date($s_created_at);
        $arr_data['api'] = $this->table_field_api();

        return $arr_data;
    }


    /**
     * state 状态值数组
     *
     * @return array
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function state_arr()
    {

        //检测状态：0无 1待检测 2检测成功 9检测失败
        $arr_check_state = [
          ['id' => -99, 'name' => '检测状态'],
          ['id' => 0, 'name' => '无'],
          ['id' => 1, 'name' => '待检测'],
          ['id' => 2, 'name' => '检测成功'],
          ['id' => 9, 'name' => '检测失败'],
        ];

        $arr_data = [
          'check_state'        => $arr_check_state,
        ];
        return $arr_data;
    }

    /**
     * 获取state值和注释的集合
     *
     * @return array
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function arr_state_name()
    {
        return $this->hi_arr_state_name($this->state_arr());
    }

    /**
     * 获取state值和注释的集合
     *
     * @return array
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function arr_state_display_name()
    {
        return $this->hi_arr_state_display_name($this->state_arr());
    }



    
  
}